<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); 
class TextArea extends codexForms
{
    function TextArea($name,$params) { 
        $params['attributes']['cols'] = (isset($params['attributes']['cols']))? $params['attributes']['cols'] : 40 ;
        $params['attributes']['rows'] = (isset($params['attributes']['rows']))? $params['attributes']['rows'] : 10 ;
        codexForms::initiate($name,$params);
    }

    function prepForDB($value){
        return (nl2br($value));
    }

    function prepForDisplay($value){
        return (stripslashes(strip_tags($value,'<br /><br>')));
    }

	function getHTML()
	{
        $html = "";
		$html .= $this->prefix;
        $html .= $this->getMessage($this->name);
        $html .= '
            <label for="'.$this->name.'">
                '.$this->label.'
            </label>
            <textarea id="'.$this->name.'" name="'.$this->name.'" '.$this->getAttributes($this->attributes).'>'.$this->br2nl(stripslashes(strip_tags($this->value))).'</textarea>
        ';
		$html .= $this->suffix;
		
		return $html;
	}
    function br2nl($text)
    {
        return  preg_replace('/<br\\\\s*?\\/??>/i', "\\n", $text);
    }
    
}
?>
